import { isPhoneNumber } from '@/utils/index'
import { status } from 'nprogress';

export const formRules = {
  name: [{ required: true, validator: notEmpty, msg: '请输入预案名称', trigger: ['blur', 'change'] }],
  type: [{ required: true, validator: notEmpty, msg: '请选择预案类型', trigger: ['blur', 'change'] }],
  departmentId: [{ required: true, validator: notEmpty, msg: '请选择编制部门', trigger: ['blur', 'change'] }],
  emergencyTime: [{ required: true, validator: notEmpty, msg: '请选择编制时间', trigger: ['blur', 'change'] }],
  accordingId: [{ required: true, validator: notEmpty, msg: '请选择编制依据', trigger: ['blur', 'change'] }],
  status: [{ required: true, validator: notEmpty, msg: '请选择状态', trigger: ['blur', 'change'] }],
  remark: [{ required: true, validator: notEmpty, msg: '请输入预案简述', trigger: ['blur', 'change'] }],
  attachment: [{ required: true, validator: notEmpty, msg: '请上传预案附件', trigger: ['blur', 'change'] }],
}



// 校验不能为空
function notEmpty(rule, value, callback) {
  if (!value) {
    if(rule.field === 'status' && value === 0){
      return callback()
    }
    return callback(new Error(rule.msg))
  }else{
    if(rule.field === 'attachment' && (!value || value.length === 0)){
      return callback(new Error(rule.msg))
    }
    return callback()
  }
}



export const personalColumn = [
  { prop: 'name', label: '姓名', align: 'center', },
  { prop: 'phone', label: '联系电话', align: 'center'},
  { prop: 'position', label: '岗位', align: 'center'},
  { prop: 'departmentId', label: '所属部门', align: 'center'},
]

export const commandColumn = [
  { prop: 'commandName', label: '指挥岗位', align: 'center', },
  { prop: 'name', label: '姓名', align: 'center', },
  { prop: 'phone', label: '联系电话', align: 'center'},
  { prop: 'position', label: '岗位', align: 'center'},
  { prop: 'departmentId', label: '所属部门', align: 'center'},
]